home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / comms / www / httpresume / rexx / demo.rexx next >
OS/2 REXX Batch file  |  1999-09-06  |  2KB  |  90 lines

  1. /* $VER: HTTPResume ARexx demo 1.2 (14.1.99)  */
  2. /*                                            */
  3. /* Reads ListFile which is in format:         */
  4. /* URL                                        */
  5. /* File name                                  */
  6. /* and downloads the whole list               */
  7. /*                                            */
  8. /* Please note that I'm not too fluent in     */
  9. /* ARexx, so excuse all the errors possibly   */
  10. /* made. Insert standard disclaimer here.     */
  11.  
  12. OPTIONS RESULTS
  13.  
  14. Path = 'PathTo:HTTPResume'
  15. ListFile = 'RAM:SomeFile.txt'
  16.  
  17. IF ~SHOW('L', 'rexxsupport.library') THEN IF ~ADDLIB('rexxsupport.library', 0, -30, 0) THEN DO 
  18.     SAY "Couldn't open rexxsupport.library!"
  19.     EXIT 10
  20. END
  21.  
  22. HPort = ADDRESS()
  23. IF (LEFT(HPort, 11) ~= 'HTTPRESUME.') THEN DO
  24.     FromHTTPResume = 0
  25.     TmpFile = 'T:HTTPResume.tmp.'||random(,,time('s'))||'.'random(,,)
  26.  
  27.     ADDRESS COMMAND 'Run '||Path||' GUI NOERRREQ RXPORTFILE='||TmpFile
  28.  
  29.     Delay(150) /* Wait 3 seconds for HTTPResume to start */
  30.  
  31.     Suc = OPEN(PortFile, TmpFile, 'R')
  32.     IF Suc ~= 1 THEN DO
  33.         SAY 'Couldn''t open temporary file!'
  34.         EXIT 20
  35.     END
  36.     Port = READLN(PortFile)
  37.     CLOSE(PortFile)
  38.     CALL DELETE(TmpFile)
  39.  
  40.     IF Port = '***' THEN DO
  41.         SAY 'HTTPResume couldn''t open its ARexx port!'
  42.         EXIT 20
  43.     END
  44.  
  45.     ADDRESS(Port)
  46. END
  47. ELSE DO
  48.     FromHTTPResume = 1
  49.     QUERY NOERRREQ
  50.     OLDERRREQ = RESULT
  51.     SET NOERRREQ
  52. END
  53.  
  54. Suc = OPEN(LFile, ListFile, 'R')
  55. IF Suc ~= 1 THEN DO
  56.     SAY 'Couldn''t open list file!'
  57.     IF FromHTTPResume = 0 THEN QUIT
  58.     EXIT 20
  59. END
  60.  
  61. DROP Data.
  62. Count = 0
  63.  
  64. DO WHILE ~EOF(LFile)
  65.     Count = Count + 1
  66.     Line = READLN(LFile)
  67.     Data.URL.Count = Line
  68.     IF ~EOF(LFile) THEN DO
  69.         Line = READLN(LFile)
  70.         Data.Outfile.Count = Line
  71.     END
  72.     ELSE Count = Count - 1
  73. END
  74. CALL CLOSE(LFile)
  75.  
  76. DO I = 1 TO Count
  77.     SET OUTFILE Data.Outfile.I  /* Always set filename first because */
  78.     SET URL Data.URL.I          /* URL will get changed if file's    */
  79.     START                       /* comment has URL in it             */
  80.     Working = 1
  81.     DO WHILE Working > 0
  82.         CALL Delay(150) /* Pause 3 seconds */
  83.         QUERY FINISHED
  84.         Working = Result
  85.     END
  86. END
  87.  
  88. IF FromHTTPResume = 1 THEN SET NOERRREQ OLDERRREQ
  89. ELSE QUIT
  90.